package com.wyh.product.controller;

import com.wyh.product.model.DO.ProductInfo;
import com.wyh.product.service.ProductInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/product")
@RestController
public class ProductInfoController {
    @Autowired
    ProductInfoService productInfoService;

    @RequestMapping("/{productId}")
    public ProductInfo selectProductById(@PathVariable("productId") Integer productId){
        return productInfoService.selectProductById(productId);
    }

    @RequestMapping("p1")
    public String p1 (String s){
        return "接收到参数s:" + s;
    }

    @RequestMapping("p2")
    public String p2 (String s, Integer i){
        return "接收到参数s:" + s + " i:" + i;
    }

    @RequestMapping("p3")
    public String p3 (ProductInfo p){
        return "接收到参数p:" + p.toString();
    }

    @RequestMapping("p4")
    public String p4 (@RequestBody ProductInfo p){
        return "接收到参数p:" + p.toString();
    }
}
